/*
**********************************************************
*
* Programme :	libcoord.c
*
* ecrit par :	Najim Boujedli et Jeremy Paneri
*
* resume :		
* 
*
*
* date : 		24/02/13
*
***********************************************************
*/

#include <stdio.h>
#include <stdlib.h>
#include <sys/time.h>
#include <math.h>
#include "libcoord.h"


TypCoord** creerTableau(int n, int graine)
{
	TypCoord** tab = malloc(n*sizeof(TypCoord*));
	int i;

	srand((unsigned long) graine);

	for (i = 0; i < n; ++i)
	{
		tab[i] = (TypCoord*) malloc(sizeof(TypCoord));
		tab[i]->x = rand() %101;
		tab[i]->y = rand() %101;
	}

	return tab;
}

void supprimerTableau(TypCoord*** tab,int n){
int i;

	for (i = 0; i < n; ++i)
	{
		free((*tab)[i]);
	}

	free(*tab);

}





void affichageTableau(TypCoord** tab, int n)
{
	int i;
	for (i = 0; i < n; ++i)
	{
		printf("%d -\tx:%d,\ty:%d\n", i, tab[i]->x, tab[i]->y);
	}
}

double calculDistance(TypCoord* coord1, TypCoord* coord2){

	int dx = coord2->x-coord1->x;
	int dy = coord2->y-coord1->y;

	return sqrt(dx*dx+dy*dy);
}






